<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta
      http-equiv="X-UA-Compatible"
      content="IE=edge"
    />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1.0"
    />
    <title>Document</title>
  </head>
  <body>
    <span id="txt"></span>
    <br />
    <input
      type="text"
      id="input"
    />
    <script>
      var obj = {}

      Object.defineProperty(obj, 'message', {
        get() {
          return obj
        },
        set(val) {
          // console.log(val)
          document.querySelector('#txt').innerHTML = val
          document.querySelector('#input').value = val
        }
      })

      // 给对象赋值
      obj.message = 'hello vue'

      document.querySelector('#input').addEventListener('input', (e) => {
        // console.log(e.target.value)
        document.querySelector('#txt').innerHTML = e.target.value
      })
    </script>
  </body>
</html>
